package daemonset

import (
	"kubernate-server/service"

	"github.com/gin-gonic/gin"
)

/**
 * Author: 张文进
 * Description: daemonsets路由规则
 * Date: 2025-09-28
 */

type K8sDaemonSetRouter struct {
}

func (*K8sDaemonSetRouter) InitK8SDaemonSetRouter(r *gin.Engine) {
	group := r.Group("/k8s/daemonset")
	group.POST("/createDaemonSet/:nameSpace", service.ApiGroupApp.CreateDaemonSet)
	group.GET("/daemonSetDetail/:nameSpace/:daemonSetName", service.ApiGroupApp.GetDaemonSetDetail)
	group.GET("/getDaemonSetList/:nameSpace", service.ApiGroupApp.GetDaemonSetList)
	group.DELETE("/delDaemonSet/:nameSpace/:daemonSetName", service.ApiGroupApp.DeleteDaemonSet)
	group.PUT("/updateDaemonSet/:nameSpace/:daemonSetName", service.ApiGroupApp.UpdateDaemonSet)
}

/*
测试案例：
1.创建DaemonSet http://127.0.0.1:8082/k8s/daemonset/createDaemonSet/:nameSpace
postman测试：
  POST http://127.0.0.1:8082/k8s/daemonset/createDaemonSet/default
请求体raw:
{
    "name": "test-daemonset",
    "image": "registry.cn-hangzhou.aliyuncs.com/yinzhengjie-k8s/apps:v1",
    "port": 80
}
结果：
{
    "data": {
        "name": "test-daemonset",
        "namespace": "default"
    },
    "message": "success"
}
*/

/*
2.获取DaemonSet列表 http://127.0.0.1:8082/k8s/daemonset/getDaemonSetList/:nameSpace
postman测试：
  GET http://127.0.0.1:8082/k8s/daemonset/getDaemonSetList/default
结果：
{
    "daemonSetList": [
        {
            "available": 2,
            "created": "2025-09-28T15:38:33Z",
            "current": 2,
            "desired": 2,
            "name": "test-daemonset",
            "namespace": "default",
            "ready": 2
        }
    ],
    "message": "success",
    "total": 1
}
*/

/*
3. 获取DaemonSet详情 http://127.0.0.1:8082/k8s/daemonset/daemonSetDetail/:nameSpace/:daemonSetName
postman测试：
GET http://127.0.0.1:8082/k8s/daemonset/daemonSetDetail/default/test-daemonset
结果：
{
    "available": 2,
    "conditions": null,
    "current": 2,
    "desired": 2,
    "labels": {
        "app": "test-daemonset"
    },
    "message": "success",
    "name": "test-daemonset",
    "namespace": "default",
    "ready": 2
}
*/

/*
4.更新DaemonSet（镜像版本） http://127.0.0.1:8082/k8s/daemonset/updateDaemonSet/:nameSpace/:daemonSetName
postman测试：
PUT http://127.0.0.1:8082/k8s/daemonset/updateDaemonSet/default/test-daemonset
请求体raw:
{
    "image": "registry.cn-hangzhou.aliyuncs.com/yinzhengjie-k8s/apps:v2"
}
结果：
{
    "data": {
        "image": "registry.cn-hangzhou.aliyuncs.com/yinzhengjie-k8s/apps:v2",
        "name": "test-daemonset",
        "namespace": "default"
    },
    "message": "success"
}
*/

/*
5. 删除 DaemonSet http://127.0.0.1:8082/k8s/daemonset/delDaemonSet/:nameSpace/:daemonSetName
postman测试：
DELETE http://127.0.0.1:8082/k8s/daemonset/delDaemonSet/default/test-daemonset
结果：
{
    "data": {
        "name": "test-daemonset",
        "namespace": "default"
    },
    "message": "success"
}
*/
